/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa036.kiss.Entity;

/**
 *
 * @author Vasa
 */
public class ZamestnanecDTO {
    
    private Long id;
    private KolejDTO kolej;
    private String jmeno;
    private String prijmeni;
    private String pozice;
    private String telefon;
    private String ulice;
    private String mesto;
    private String psc;
    private String username;
    private String heslo;

  public Long getId () {

    return this.id;
  }

  public ZamestnanecDTO setId ( final Long id ) {

    if ( id != null ) {

      this.id = new Long ( id.longValue () );
    }

    return this;
  }

    public String getJmeno() {
        return jmeno;
    }

    public void setJmeno(String jmeno) {
        this.jmeno = jmeno;
    }

    public String getPrijmeni() {
        return prijmeni;
    }

    public void setPrijmeni(String prijmeni) {
        this.prijmeni = prijmeni;
    }

    public String getPozice() {
        return pozice;
    }

    public void setPozice(String pozice) {
        this.pozice = pozice;
    }

    public String getTelefon() {
        return telefon;
    }

    public void setTelefon(String telefon) {
        this.telefon = telefon;
    }

    public String getUlice() {
        return ulice;
    }

    public void setUlice(String ulice) {
        this.ulice = ulice;
    }

    public String getMesto() {
        return mesto;
    }

    public void setMesto(String mesto) {
        this.mesto = mesto;
    }

    public String getPsc() {
        return psc;
    }

    public void setPsc(String psc) {
        this.psc = psc;
    }

    public KolejDTO getKolej() {
        return kolej;
    }

    public void setKolej(KolejDTO kolej) {
        this.kolej = kolej;
    }

    public String getHeslo() {
        return heslo;
    }

    public void setHeslo(String heslo) {
        this.heslo = heslo;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

  @Override
  public boolean equals ( final Object rhs ) {

    if ( this == rhs ) return true;

    if ( rhs == null ) return false;

    if ( this.getClass () != rhs.getClass () ) return false;

    final ZamestnanecDTO c = (ZamestnanecDTO) rhs;

    return this.id == null ? c.id == null : this.id.equals ( c.id ) &&
        this.kolej == null ? c.kolej == null : this.kolej.equals ( c.kolej ) &&
        this.jmeno == null ? c.jmeno == null : this.jmeno.equals ( c.jmeno ) &&
        this.prijmeni == null ? c.prijmeni == null : this.prijmeni.equals ( c.prijmeni ) &&
        this.pozice == null ? c.pozice == null : this.pozice.equals ( c.pozice ) &&
        this.telefon == null ? c.telefon == null : this.telefon.equals ( c.telefon ) &&
        this.ulice == null ? c.ulice == null : this.ulice.equals ( c.ulice ) &&
        this.mesto == null ? c.mesto == null : this.mesto.equals ( c.mesto ) &&
        this.psc == null ? c.psc == null : this.psc.equals ( c.psc ) &&
        this.username == null ? c.username == null : this.username.equals ( c.username ) &&
        this.heslo == null ? c.heslo == null : this.heslo.equals ( c.heslo );
  }

  @Override
  public int hashCode () {

    final int[] hashCodes = {
        (this.id == null) ? 0 : this.id.hashCode (),
        (this.kolej == null) ? 0 : this.kolej.hashCode (),
        (this.jmeno == null) ? 0 : this.jmeno.hashCode (),
        (this.prijmeni == null) ? 0 : this.prijmeni.hashCode (),
        (this.pozice == null) ? 0 : this.pozice.hashCode (),
        (this.telefon == null) ? 0 : this.telefon.hashCode (),
        (this.ulice == null) ? 0 : this.ulice.hashCode (),
        (this.mesto == null) ? 0 : this.mesto.hashCode (),
        (this.psc == null) ? 0 : this.psc.hashCode (),
        (this.username == null) ? 0 : this.username.hashCode (),
        (this.heslo == null) ? 0 : this.heslo.hashCode ()
    };

    int hash = 17;
    for ( final int currentHashCode: hashCodes ) {

      hash = hash * 31 + currentHashCode;
    }

    return hash;
  }

  @Override
  public Object clone () {

    try {

      return ( (ZamestnanecDTO) super.clone () ).setId ( this.id );
    } catch ( CloneNotSupportedException ex ) {

      assert false: "CloneNotSupportedException thrown";
      return null;
    }
  }

  @Override
  public String toString () {

    return this.id + ": " + this.jmeno + " "  + this.prijmeni+ ", "  + this.ulice
        + ", " + this.mesto + ", " + this.psc + ", " + this.username + ": " + this.heslo
    ;
  }

  /**
   * Determine whether the person has set necessary information
   */
  public void checkState () {

    final boolean noJmeno = this.jmeno == null || this.jmeno.isEmpty ();
    final boolean noPrijmeni = this.prijmeni == null || this.prijmeni.isEmpty ();
    final boolean noUsername = this.username == null || this.username.isEmpty ();
    final boolean noHeslo = this.heslo == null || this.heslo.isEmpty ();

    if ( noJmeno && noPrijmeni && noUsername && noHeslo )  {

      throw new IllegalStateException ( "Jmeno, prijmeni, username a heslo musi byt nastaveny" );
    }
  }
}
